package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.List;
/*11111111111111111111111111111111111111111111111111111111111111111111111*/
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    /**
     * @description: 客户列表分页
     * http://localhost:8080/customer/list
     * @author 化一帆
     * @date 2023/2/10 9:56
     */

    @PostMapping("/list")
    public Map<String,Object> list(Integer page, Integer rows, String  customerName){
        return customerService.list(page,rows,customerName);
    }

    /**
     * @description:添加或者修改客户
     * 根据customerId进行判断
     * http://localhost:8080/ customer/save?customerId=1
     * @author 化一帆
     * @date 2023/2/10 10:55
     */

    @PostMapping("/save")
    public ServiceVO save(Customer customer){
        return customerService.save(customer);
    }

    /**
     * @description: 客户删除
     * http://localhost:8080/customer/delete
     * @author 化一帆
     * @date 2023/2/10 11:19
     */

    @PostMapping("/delete")
    public ServiceVO delete(String ids){
        return customerService.delete(ids);
    }
}
